what could cause a script to fail to find python when it has `#!/usr/bin/env python` in the first line?

Posted by jcollum on Ask Ubuntu See other posts from Ask Ubuntu or by jcollum
Published on 2013-11-07T20:25:03Z Indexed on 2013/11/07 22:21 UTC
Read the original article Hit count: 373

Filed under:
|
|

Trying to get casperjs running on Ubuntu 12.04. After installing it when I run I get:

09:20 $ ll /usr/local/bin/casperjs
lrwxrwxrwx 1 root root 26 Nov  6 16:49 /usr/local/bin/casperjs -> /opt/casperjs/bin/casperjs

09:20 $ /usr/bin/env python --version
Python 2.7.3

09:20 $ cat /opt/casperjs/bin/casperjs | head -4 
#!/usr/bin/env python

import os
import sys

09:20 $ casperjs
: No such file or directory

09: 22 $ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06) 
[GCC 4.6.3] on linux2

So Python is present and runnable, casperjs is pointing to the right place and it is a python script. But when I run it I get "No such file".

I can fix it by changing the first line of the casperjs python file from:

#!/usr/bin/env python

to:

#!/usr/bin/python

Result:

$ casperjs --version
1.1.0-DEV

I managed to fix it, but I'm wondering why it didn't work with #!/usr/bin/env python, since that seems to be a normal interpreter line. Do I have something configured wrong?

Here are the steps to get casperjs:

$ git clone git://github.com/n1k0/casperjs.git
$ cd casperjs
$ ln -sf `pwd`/bin/casperjs /usr/local/bin/casperjs
$ casperjs
: No such file or directory

© Ask Ubuntu or respective owner

Related posts about bash

Related posts about python